	/**
		左右移动的多选筐
	**/
	function DoubleSelect(dSelectId, data) {
		this.dSelectId = dSelectId;
		if (data && data != null && data != "" && data != "null") {
			this.value = data.split(",");
		} else {
			this.value = null;
		}
		this.obj = document.getElementById(dSelectId);
		this.objLeft = document.getElementById(this.dSelectId + ".left");
		this.objRight = document.getElementById(this.dSelectId + ".right");
		this.btLeft = document.getElementById(this.dSelectId + ".btleft");
		this.btRight = document.getElementById(this.dSelectId + ".btright");
		this.btUp = document.getElementById(this.dSelectId + ".btup");
		this.btDown = document.getElementById(this.dSelectId + ".btdown");
		
		//动态获取选项的相关参数
		this.url = this.obj.getAttribute("url");
		this.content = this.obj.getAttribute("content");
			
		if (this.url == null && this.content != null) {
			//需要根据个各项目定义的通用获取option的链接
			this.url = "/content.xml?content=" + this.content;
		}
		this.method = this.obj.getAttribute("method");
		this.valueProperty = this.obj.getAttribute("valueProperty");
		this.textProperty = this.obj.getAttribute("textProperty");
					
		//记录dependon的参数
		this.param = {};
		this.free = {};
		this.removeParam = function (paramName) {
			if (paramName && paramName != "")
				delete this.param[paramName];
		};
		this.setParam = function (paramName, paramValue) {	
			if (paramName && paramName != "" && paramValue && paramValue != "") {
				this.param[paramName] = paramValue;
			}	
		};
		this.getParam = function () {
			return hashToParam(this.param);
		}
		this.isFree = function () {
			return hashToBool(this.free);
		}
		
		this.init();
	}
	
	DoubleSelect.prototype.init = function () {
		//初始化选中的选项
		var optionsObj = this.objRight.options;
		for (var i = 0; i < this.value.length; i++) {
			for (var k = optionsObj.length - 1; k >= 0; k--) {
				if (optionsObj.item(k).value == this.value[i]) {
					var optObjs = document.createElement("OPTION");
					optObjs.value = optionsObj.item(k).value;
					optObjs.text = optionsObj.item(k).text;
					if (document.all) {
						this.objLeft.add(optObjs);
					} else {
						this.objLeft.appendChild(optObjs);
					}
					this.objRight.removeChild(optionsObj.item(k));
					break;
				}
			}
		}
		this.rebuild();
		
		//添加相应的事件
		var oThis = this;
		this.btLeft.onclick = function () {
			oThis.moveLeft();
		}
		this.btRight.onclick = function () {
			oThis.moveRight();
		}
		this.btUp.onclick = function () {
			oThis.moveUp();
		}
		this.btDown.onclick = function () {
			oThis.moveDown();
		}
	};
	//根据选中的值,从新给hidden域赋值
	DoubleSelect.prototype.rebuild = function () {
		var optionsObj = this.objLeft.options;
		var o = "";
		for (var k = 0; k < optionsObj.length; k++) {
			o = o + optionsObj.item(k).value + ",";
		}
		
		//新值和旧值不同，onchange
		var oldValue = this.obj.value;
		var newValue = o.substring(0, o.length - 1);
		if (oldValue != newValue) {
			this.obj.value = newValue;
			if (typeof this.obj.onchange == "function") {
				this.obj.onchange();
			}
			if (typeof this.onchange == "function") {
				this.onchange();
			}
		}
	};
	
	//上移
	DoubleSelect.prototype.moveUp = function () {
		var optionsObj = this.objLeft.options;
		for (var k = 0; k < optionsObj.length; k++) {
			if (optionsObj.item(k).selected && k != 0) {
				var value = optionsObj.item(k).value;
				var text = optionsObj.item(k).text;
				optionsObj.item(k).value = optionsObj.item(k - 1).value;
				optionsObj.item(k).text = optionsObj.item(k - 1).text;
				optionsObj.item(k).selected = false;
				optionsObj.item(k - 1).value = value;
				optionsObj.item(k - 1).text = text;
				optionsObj.item(k - 1).selected = true;
			}
		}
		this.rebuild();
	};
	
	//下移
	DoubleSelect.prototype.moveDown = function () {
		var optionsObj = this.objLeft.options;
		for (var k = optionsObj.length - 1; k >= 0; k--) {
			if (optionsObj.item(k).selected && k != optionsObj.length - 1) {
				var value = optionsObj.item(k).value;
				var text = optionsObj.item(k).text;
				optionsObj.item(k).value = optionsObj.item(k + 1).value;
				optionsObj.item(k).text = optionsObj.item(k + 1).text;
				optionsObj.item(k).selected = false;
				optionsObj.item(k + 1).value = value;
				optionsObj.item(k + 1).text = text;
				optionsObj.item(k + 1).selected = true;
			}
		}
		this.rebuild();
	};
	
	//选中
	DoubleSelect.prototype.moveLeft = function () {
		var optionsObj = this.objRight.options;
		for (var k = optionsObj.length - 1; k >= 0; k--) {
			if (optionsObj.item(k).selected) {
				var optObjs = document.createElement("OPTION");
				optObjs.value = optionsObj.item(k).value;
				optObjs.text = optionsObj.item(k).text;
				if (document.all) {
					this.objLeft.add(optObjs);
				} else {
					this.objLeft.appendChild(optObjs);
				}
				this.objRight.removeChild(optionsObj.item(k));
			}
		}
		this.rebuild();
	};
	
	//去除
	DoubleSelect.prototype.moveRight = function () {
		var optionsObj = this.objLeft.options;
		for (var k = optionsObj.length - 1; k >= 0; k--) {
			if (optionsObj.item(k).selected) {
				var optObjs = document.createElement("OPTION");
				optObjs.value = optionsObj.item(k).value;
				optObjs.text = optionsObj.item(k).text;
				if (document.all) {
					this.objRight.add(optObjs);
				} else {
					this.objRight.appendChild(optObjs);
				}
				this.objLeft.removeChild(optionsObj.item(k));
			}
		}
		this.rebuild();
	};
	
	//清空选项
	DoubleSelect.prototype.clearOption = function () {
		if (typeof this.onOptionUnload == "function") {
			this.onOptionUnload();
		}
		
		var optionsObj = this.objRight.options;
		for (k = optionsObj.length - 1; k >= 0 ; k --) {
			this.objRight.removeChild(optionsObj.item(k));
		}
		
		optionsObj = this.objLeft.options;
		for (k = optionsObj.length - 1; k >= 0 ; k --) {
			this.objLeft.removeChild(optionsObj.item(k));
		}
		
		this.obj.value = "";
	}
	
	//添加新的选项
	DoubleSelect.prototype.addOption = function (value, text) {
		//判断是否选中
		var selected = false;
		if (this.value) {
			for (i = 0;i < this.value.length;i ++) {
				if (value == this.value[i]) {
					selected = true;
					break;	
				}
			}
		}
		
		//生成
		var optObjs = document.createElement("OPTION");
		optObjs.value = value;
		optObjs.text = text;
		
		//添加
		if (!selected) {
			//添加到右边
			if (document.all) {
				this.objRight.add(optObjs);
			} else {
				this.objRight.appendChild(optObjs);
			}
		} else {
			//添加到左边
			if (document.all) {
				this.objLeft.add(optObjs);
			} else {
				this.objLeft.appendChild(optObjs);
			}
			var optionsObj = this.objLeft.options;
			var o = "";
			for (var k = 0; k < optionsObj.length; k++) {
				o = o + optionsObj.item(k).value + ",";
			}
			this.obj.value = o.substring(0, o.length - 1);
		}
	}
	
	//获取项
	DoubleSelect.prototype.fetchOption = function () {
		//url空，表示改select控件不是需要动态改变可选项的
		if (this.url == null) return;
		//处理带入的参数
		var fp = this.getParam();
		var fu = (fp && fp != null)?this.url + fp:this.url;
		
		//通过http提交请求
		var http = new HttpObject();
		var ret = null;
		if (this.method == 'POST')
			ret = http.httpPostReturnMaps(this.url, fp);
		else
			ret = http.httpGetReturnMaps(fu);
			
		//处理获取的数据
		if (isValid(this.valueProperty) && isValid(this.textProperty)) {
			//清除现有选项
			this.clearOption();
			//新增选项
			for (var i = 0; i < ret.length; i ++) {
				var v = ret[i][this.valueProperty];
				var t = ret[i][this.textProperty];	
				this.addOption(v, t);
			}
				
			if (typeof this.onOptionLoad == "function") {
				this.onOptionLoad();
			}
		}
	}
	
	//依赖关系
	DoubleSelect.prototype.dependOn = function (dependOnId, weakDepend, dependParam) {
		var obj = this;
		
		var dependObj = document.getElementById(dependOnId);
		if (dependObj) {
			var change = function () {
				//以下是和控件相关的方法
				//如果依赖的控件值不为空
				if (dependObj.value && dependObj.value != "") {
					//允许改依赖开锁
					obj.free[dependOnId] = true;
					//参数带入
					if (dependParam) {
						obj.setParam(dependParam, dependObj.value);
					} else {
						obj.setParam(dependObj.name, dependObj.value);
					}
					//获取选项
					if (obj.isFree())
						obj.fetchOption();
				
				//如果依赖的控件值空
				} else {
					if (dependParam) {
						obj.removeParam(dependParam);
					} else {
						obj.removeParam(dependObj.name);
					}
					
					//如果弱依赖关系，那么则获取选项
					if (weakDepend) {
						obj.free[dependOnId] = true;
						if (obj.isFree())
							obj.fetchOption();
					//不是弱依赖关系，那么清除所有选项	
					} else {
						obj.free[dependOnId] = false;
						obj.clearOption();
					}
				}
			}
			//IE
			if (document.all)
				dependObj.attachEvent("onchange", change);
			//FireFox
			else
				dependObj.addEventListener("change", change, false);
			change();
		}
	}
	
